/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author bienphongvnn
 */
public class GiaVeModel {
    public static double layTien(String MaTuyen){
        double giave = 0;
        Connection con = ConnectionProvider.Connect();
	try {
            String sql = String.format("select GiaVe from giave where MaTuyen = ( select MaTuyen from tuyentau where TenTuyen = '%s')", MaTuyen);
            Statement statement	= con.createStatement();		
            ResultSet rs = statement.executeQuery(sql);	
            while(rs.next()){	
                giave = rs.getDouble("GiaVe");
                } 
            con.close();
        }
        catch(Exception ex){
            System.out.println(ex.getMessage());	
        }
        finally
        {
           
        }
        return	giave;
     }
}
